extends KinematicBody2D

var player
var target_pos 

var speed = 3

var catched = false

signal life_jian

func _ready():
	connect("life_jian",get_tree().current_scene.get_node("HBoxContainer/life"),"lifejian")
	player = get_parent().get_node("player")
	pass # Replace with function body.

func _physics_process(delta):
	if is_instance_valid(player):
		var target_pos = player.global_position
		if target_pos.distance_to(global_position) >0:
			if player.visable_to_eagle:
				global_position = global_position.move_toward(target_pos,speed)
	#print(player)


func _on_Area2D_body_entered(body):
	if body.name == "player":
		catched = true
		emit_signal("life_jian")
		self.position = Vector2(0,0)
		player.position = Vector2(1190,642)
	pass
